package com.lmj.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lmj.dto.DataRequest;
import com.lmj.dto.DataResponse;
import com.lmj.mapper.HandposeMapper;
import com.lmj.pojo.Handpose;
import com.lmj.service.HandposeService;
import com.lmj.utils.RequestBody;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

@Service
public class HandposeServiceImpl extends ServiceImpl<HandposeMapper, Handpose> implements HandposeService {

    @Resource
    private HandposeMapper handposeMapper;

    // 响应体
    private DataResponse dataResponse;
    // 响应数据
    private Map<String, String> map = new HashMap<>();

    public DataResponse getHandpose(String request) {
        DataRequest requestBody = RequestBody.getRequestBody(request);

        Long handDictionaryId = requestBody.getLong("handDictionaryId");
        Long handposeId = requestBody.getLong("handposeId");

        LambdaQueryWrapper<Handpose> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.eq(Handpose::getHandDictionaryId, handDictionaryId);
        queryWrapper.eq(Handpose::getHandposeId, handposeId);
        Handpose handpose = handposeMapper.selectOne(queryWrapper);

        map.clear();

        map.put("handposeName", handpose.getHandposeName().toString());
        map.put("handposeDescription", handpose.getHandposeDescription().toString());
        map.put("handposePicture", handpose.getHandposePicture().toString());

        return new DataResponse("200", map);
    }

}
